package com.topnav.mc.study.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.base.query.ExtensionMapper;
import com.topnav.mc.study.entity.Study;
import com.topnav.mc.study.entity.StudyOrg;
import com.topnav.mc.study.entity.StudyParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudyMapper extends ExtensionMapper<Study,StudyOrg,StudyParam> {
    @Select("SELECT S.*,o.name AS orgName FROM study s LEFT JOIN mc_organization o ON s.org_id = o.id ${ew.customSqlSegment}")
    StudyOrg selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select("SELECT S.*,o.name AS orgName FROM study s LEFT JOIN mc_organization o ON s.org_id = o.id ${ew.customSqlSegment} ")
    List<StudyOrg> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select("SELECT S.*,o.name AS orgName FROM study s LEFT JOIN mc_organization o ON s.org_id = o.id ${ew.customSqlSegment}")
    <E extends IPage<StudyOrg>> E selectInfoPage(Page<StudyParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);
}
